Fix cases for qml.sample(..., counts=True)#2839
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2839 +/- ##
========================================
Coverage 99.63% 99.63%
========================================
Files 251 252 +1
Lines 20572 20757 +185
========================================
+ Hits 20496 20681 +185
Misses 76 76
Continue to review full report at Codecov.
|
rmoyard
left a comment
There was a problem hiding this comment.
Great changes @antalszava, I am glad that it is working as expected 💯 I've left some comments. One thing that is out of scope of this PR is that I would find great that we always return the dictionary for every state:
{'001': 7, '111': 3} could become {'000': 0, 001': 7, '010': 0, '011': 0, '100': 0, '101': 0, '110': 0 '111': 3}
|
@rmoyard thanks for the comments!
Good point! Could it be user-dependent, i.e., some prefer this some prefer that? Would it be worth having kwarg for it? |
That could be done with |
albi3ro
left a comment
There was a problem hiding this comment.
Left some minor, optional potential improvements.
Excellent job getting this to work!
Co-authored-by: Christina Lee <christina@xanadu.ai>
Co-authored-by: Christina Lee <christina@xanadu.ai>
… approach pops items on first use
|
[sc-23475] |
rmoyard
left a comment
There was a problem hiding this comment.
Thanks @antalszava, it looks good on my side 💯
albi3ro
left a comment
There was a problem hiding this comment.
Looks good to go from my side.
|
Created an issue for returning or states with counts: From my side, I'm still wondering about the refactor to the |
Context:
In a recent PR it was found that the
qml.shots(..., counts=True)behaves in unexpected ways in some cases. The original addition was made in this PR.Description of the Change:
Fixed the use of returning counts when:
Note that counts now no longer return tensor objects, but rather raw dictionaries or sequences that contain dictionaries.
Benefits:
Returning counts works in more cases as expected.
Possible Drawbacks:
N/A
Related GitHub Issues:
N/A